#! /bin/sh
# Xdemo1 - simple example script for sufdmod1, X window graphics
# N. Maercklin, Oct. 2006

# Output file names (velocity,density and seismogram):
vfile=velocity.bin
dfile=density.bin
sufile=seismogram.su

# Velocity and density model:
depth=0,600,601,1200,1201,1500,1501,2000
velo=2000,2000,3000,3000,2600,2600,4500,4500
dens=1.5,1.5,2.0,2.0,2.0,2.0,2.6,2.6
nz=2001
dz=1

# Modelling parameters:
sz=1       # source depth
rz=1       # receiver depth
tmax=1.5   # max. time of seismogram
styp=1     # source type (0, 1, or 2)
abs=1,1    # boundary conditions


# Make models:
unisam xin=$depth yin=$velo dxout=$dz nout=$nz > $vfile
unisam xin=$depth yin=$dens dxout=$dz nout=$nz > $dfile

# Show velocity model:
xgraph <$vfile n=$nz d1=$dz pairs=0 x2beg=1000 x2end=5000 \
    label1="depth (m)" label2="velocity (m/s)" linecolor=2 \
    title="velocity model" windowtitle="velocity" style=seismic \
    -geometry 240x300+50+50 &

# Show density model:
xgraph <$dfile n=$nz d1=$dz pairs=0 x2beg=1.0 x2end=3.0 \
    label1="depth (m)" label2="density (g/cm3)" linecolor=3 \
    title="density model" windowtitle="density" style=seismic \
    -geometry 240x300+300+50 &


# Make seismogram:
sufdmod1 <$vfile nz=$nz dz=$dz sz=$sz rz=$rz tmax=$tmax \
    abs=$abs styp=$styp dfile=$dfile >$sufile

# Show seismogram:
suxgraph <$sufile label1="time (s)" linecolor=4 \
    windowtitle="seismogram" title="seismogram" \
    -geometry 240x300+550+50 &

# Echo output file names to stderr:
echo "${0}: wrote $vfile, $dfile, and $sufile" 1>&2

exit 0
